* Table 10
local table "Table10"
use "./data/academics.dta", clear
createvarsacad
keep if tenure
qui putexcel set "./tables/tables.xlsx", sheet("`table'") modify
gen age=year-byear
gen phdyrs=year-phdyear
qui putexcel C1=("Age")
qui putexcel F1=("Years since PhD")
qui putexcel B2=("2001")
qui putexcel C2=("2009")
qui putexcel D2=("2018")
qui putexcel E2=("2001")
qui putexcel F2=("2009")
qui putexcel G2=("2018")
qui putexcel A3=("Assistant")
qui putexcel A4=("Associate")
qui putexcel A5=("Full")
qui putexcel A6=("All")
* age
qui sum age if year==2001 & newcat==10, meanonly /* PROFESSOR AUXILIAR */
qui putexcel B3=(`r(mean)'), nformat(#.0)
qui sum age if year==2009 & newcat==10, meanonly /* PROFESSOR AUXILIAR */
qui putexcel C3=(`r(mean)'), nformat(#.0)
qui sum age if year==2018 & newcat==10, meanonly /* PROFESSOR AUXILIAR */
qui putexcel D3=(`r(mean)'), nformat(#.0)
qui sum age if year==2001 & newcat==8, meanonly /* PROFESSOR ASSOCIADO */
qui putexcel B4=(`r(mean)'), nformat(#.0)
qui sum age if year==2009 & newcat==8, meanonly /* PROFESSOR ASSOCIADO */
qui putexcel C4=(`r(mean)'), nformat(#.0)
qui sum age if year==2018 & newcat==8, meanonly /* PROFESSOR ASSOCIADO */
qui putexcel D4=(`r(mean)'), nformat(#.0)
qui sum age if year==2001 & newcat==12, meanonly /* PROFESSOR CATEDRATICO */
qui putexcel B5=(`r(mean)'), nformat(#.0)
qui sum age if year==2009 & newcat==12, meanonly /* PROFESSOR CATEDRATICO */
qui putexcel C5=(`r(mean)'), nformat(#.0)
qui sum age if year==2018 & newcat==12, meanonly /* PROFESSOR CATEDRATICO */
qui putexcel D5=(`r(mean)'), nformat(#.0)
qui sum age if year==2001 
qui putexcel B6=(`r(mean)'), nformat(#.0)
qui sum age if year==2009 
qui putexcel C6=(`r(mean)'), nformat(#.0)
qui sum age if year==2018 
qui putexcel D6=(`r(mean)'), nformat(#.0)
* Years since PhD
qui sum phdyrs if year==2001 & newcat==10, meanonly /* PROFESSOR AUXILIAR */
qui putexcel E3=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2009 & newcat==10, meanonly /* PROFESSOR AUXILIAR */
qui putexcel F3=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2018 & newcat==10, meanonly /* PROFESSOR AUXILIAR */
qui putexcel G3=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2001 & newcat==8, meanonly /* PROFESSOR ASSOCIADO */
qui putexcel E4=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2009 & newcat==8, meanonly /* PROFESSOR ASSOCIADO */
qui putexcel F4=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2018 & newcat==8, meanonly /* PROFESSOR ASSOCIADO */
qui putexcel G4=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2001 & newcat==12, meanonly /* PROFESSOR CATEDRATICO */
qui putexcel E5=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2009 & newcat==12, meanonly /* PROFESSOR CATEDRATICO */
qui putexcel F5=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2018 & newcat==12, meanonly /* PROFESSOR CATEDRATICO */
qui putexcel G5=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2001 
qui putexcel E6=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2009 
qui putexcel F6=(`r(mean)'), nformat(#.0)
qui sum phdyrs if year==2018 
qui putexcel G6=(`r(mean)'), nformat(#.0)
